<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<?
include "../db_config.php";
include "Database.class.php";
include_once "snoopy/Snoopy.class.php";

$db = new Database($host_name, $user_name, $db_password, $db_name);
$db->connect();

$update = array();
$update[stationName] = '기능';
$where = "stationId = '1907'";
$r = $db->query_update('stationInfo', $update, $where);
print_r($r);
$db->close();

exit(0);




function findstr(&$source, $startkey, $endkey, &$offset)
{
	$s = strpos($source, $startkey, $offset)+strlen($startkey);
	$e = strpos($source, $endkey, $s);
	//$str = substr($source, $s, $e-$s-strlen($endkey)+1);
	$str = substr($source, $s, $e-$s);
	$offset = $e + strlen($endkey)-1;
	return $str;
}

$source =
"<tr height=20 bgcolor=\"#FFFFFF\" align=\"center\" class=\"form_schedule_left\">  
	<td ><font color='black'>건대입구</b></font></td> 
	<td >05:48:30</b></td>
	<td >05:49:00</b></td>  
	<td ></b></td>

</tr>
	
<tr height=20 bgcolor=\"#FFFFFF\" align=\"center\" class=\"form_schedule_left\">  
	<td ><font color='black'>구의</b></font></td> 
	<td >05:51:00</b></td>
	<td >05:51:30</b></td>  
	<td ></b></td>
</tr>
";
$key = "class=\"form_schedule_left\">  
	<td ><font color='black'>";
$end = "</b></font>";
$offset = 0;

while(strpos($source, $key, $offset))
{
	$key2 = "<td >";
	$end2 = "</b></td>";
	$sname = findstr($source, $key, $end, $offset);
	$start_time = findstr($source, $key2, $end2, $offset);
	$end_time = findstr($source, $key2, $end2, $offset);
	//$sname = str_replace("<b>", "", $sname);
	//echo "$sname $start $end <BR>\n";
	echo "$sname $start_time $end_time <BR>\n";
}
	

?>
